#include "FifoEscritura.h"

FifoEscritura::FifoEscritura(const std::string nombre) :
		Fifo(nombre) {
}

FifoEscritura::~FifoEscritura() {
}

void FifoEscritura::abrir() throw (CantOpenException) {
	fd = open(nombre.c_str(), O_WRONLY);
	if (fd < 0) {
		throw(CantOpenException());
	}
}

ssize_t FifoEscritura::escribir(const void* buffer,
		const ssize_t buffsize) const throw (CantWriteException) {
	int writeResult = write(fd, buffer, buffsize);
	if (writeResult <= 0) {
		throw(CantWriteException());
	}
	return writeResult;
}
